<template>
	<view>
	<up-tabbar
		:value="ee.pageBarName"
		@change="onchange"
		:fixed="true"
		:placeholder="true"
		:safeAreaInsetBottom="true"
	>
		<up-tabbar-item text="首页" name="home" icon="home-fill" @click="onclick" ></up-tabbar-item>
		 
		<up-tabbar-item text="消息" name="message" icon="chat-fill" @click="onclick" ></up-tabbar-item>
		<up-tabbar-item text="我的" name="account" icon="account-fill" @click="onclick" ></up-tabbar-item>
	</up-tabbar>	
	
	
</view> 
</template>

<script>
	export default {
		name:"kb-page-bar",
		emits: [ 'changeItem'], 
		props:{
			//属性供外部设置当前的选中tab的name
			current:{
				type : String,
				value: 'home',
				
			}
		},
		data() {
			return {
				showbind: undefined, 
			};
		},
		watch:{
			current:{
				immediate: true,
				handler (newValue, oldValue) {
					// 内外部值不相等时，才尝试移动滑块
					if (newValue !== this.ee.pageBarName) {
						this.ee.setPageBarName(newValue )
					}
				}
			} 
		},
		methods:{ 
			onclick( name ){
				this.$emit("changeItem", name)
				// console.log(getCurrentPages())
				// if(name =='home')
				// 	uni.switchTab({
				// 		url: "/pages/index/index",
				// 	}) 
				// if(name == 'message')
				// 	uni.switchTab({
				// 		url:  "/pages/tallk/index" ,
				// 	 }) 
				 
				// return ;	 
			},
			onchange( name ){
				this.ee.setPageBarName(name )
			}
		}
	}
</script>

<style lang="scss">
.page-bar{ 
}
</style>